package com.wuxiaofan.product.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuxiaofan.product.entity.AttrGroup;
import com.wuxiaofan.product.entity.custom.AttrGroupCustom;
import com.wuxiaofan.product.mapper.AttrGroupMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wuxiaofan.product.client.Idgenerator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

@Service
public class AttrGroupService {
    @Autowired
    private AttrGroupMapper pmsAttrGroupMapper;
    @Resource
    private Idgenerator idgenerator;
    public List<AttrGroupCustom> findByCategoryId(String categoryId){
        Map paraMap = new HashMap();
        paraMap.put("catelogId",categoryId);
        return findByMap(paraMap);
    }


    public AttrGroup findById(String id){
        return pmsAttrGroupMapper.selectById(id);
    }

    public AttrGroupCustom findCountByMap(Map paraMap){
        return pmsAttrGroupMapper.findCountByMap(paraMap);
    }

    public AttrGroupCustom findGroupByMap(Map paraMap){
        return pmsAttrGroupMapper.findGroupByMap(paraMap);
    }

    public List<AttrGroupCustom> findByMap(Map paraMap){
        return pmsAttrGroupMapper.findByMap(paraMap);
    }

    public Page<AttrGroupCustom> findByMap(Map paraMap, Page page){
        return page.setRecords(pmsAttrGroupMapper.findByMap(paraMap,page));
    }


    public void updateMapById(Map paraMap){
        pmsAttrGroupMapper.updateMapById(paraMap);
    }
    public void delById(String id){
        pmsAttrGroupMapper.deleteById(id);
    }

    public AttrGroup save(AttrGroup pmsAttrGroup){
        pmsAttrGroup.setAttrGroupId(idgenerator.getId());
        pmsAttrGroupMapper.insert(pmsAttrGroup);
        return pmsAttrGroup;
    }

}
